﻿package model.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import model.business.bill.Bill;

@Entity
@Table(name = "ConcreteBill")
public class ConcreteBill extends Bill {

	@Id
	@GeneratedValue(generator = "ConcreteBill_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "ConcreteBill_ID_Gen", sequenceName = "ConcreteBill_SEQ_ID")
	private int id;

	@Column(nullable = false)
	private Date createDate;

	@ManyToOne
	@JoinColumn(nullable=false)
	private Employee cashier;

	@ManyToOne
	@JoinColumn(nullable=true)
	//Ket noi voi bang Member de truy van, neu kh ko phai la Member (TempCustomer) thi = null
	private Member customer; 
	
	private long customerCreditNum;
	private String customerSignanture;
	private int moneySum;

	@OneToMany(mappedBy = "bill")
	private List<BillItem> productList;

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	public Employee getCashier() {
		return cashier;
	}

	public void setCashier(Employee cashier) {
		this.cashier = cashier;
	}

	public Member getCustomer() {
		return customer;
	}

	public void setCustomer(Member customer) {
		this.customer = customer;
	}

	public long getCustomerCreditNum() {
		return customerCreditNum;
	}

	public void setCustomerCreditNum(long customerCreditNum) {
		this.customerCreditNum = customerCreditNum;
	}

	public String getCustomerSignanture() {
		return customerSignanture;
	}

	public void setCustomerSignanture(String customerSignanture) {
		this.customerSignanture = customerSignanture;
	}

	public int getMoneySum() {
		return moneySum;
	}

	public void setMoneySum(int moneySum) {
		this.moneySum = moneySum;
	}

	public List<BillItem> getProductList() {
		return productList;
	}

	public void setProductList(List<BillItem> productList) {
		this.productList = productList;
	}

	public int getId() {
		return id;
	}
	
	@Override
	public String toString() {
		return "ConcreteBill [id=" + id + ", createDate=" + createDate
				+ ", cashier=" + cashier + ", customer=" + customer
				+ ", customerCreditNum=" + customerCreditNum
				+ ", customerSignanture=" + customerSignanture + ", moneySum="
				+ moneySum + ", productList=" + productList + "]";
	}

	public int cost() {
		return 0;
	}

}
